#!/usr/bin/env python

from iwin.db.stock.price_li import price_li
from iwin.db.stock.dividend import dividend
from tzutil.day import day2str
from iwin.db import PG


def main(code):
    market = 'HK'
    code_id = PG.select_one(
        'stock.code', dict(market=market, code=str(int(code)))
    ).id
    dividend[market](code_id, code)
    for i in price_li[market](code_id, code):
        i[0] = day2str(i[0])
        print(i)


if __name__ == "__main__":
    main(656)
